import React, { useState } from 'react';
import { Input, Button } from 'antd';


const Search = ({ onSearch }) => {
  const [searchText, setSearchText] = useState('');

  const handleSearch = () => {
    onSearch(searchText);
  }

  return (
    <div class="search">
      <Input
        placeholder="Enter product name"
        allowClear
        value={searchText}
        onChange={(e) => setSearchText(e.target.value)}
        onSearch={handleSearch}
        style={{ width: 200 }}
      />
      &nbsp;&nbsp;
      <Button type="primary" onClick={handleSearch}>Search</Button>
    </div>
  );
};

export default Search;